import java.util.Objects;

/**
 * @author lichenxi
 * @date 2020/4/3
 */
public class Point {
    private double x;
    private double y;


    public static Point[] getPoints(Vector[] vectors){
        Point[] points = new Point[vectors.length];
        for (int i = 0; i < vectors.length; i++) {
            if (vectors[i].getlen()!=2){
                throw new RuntimeException("必须是二维向量");
            }
            points[i] = new Point(vectors[i].values[0],vectors[i].values[1]);
        }
        return points;
    }

    Point(double x,double y){
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Point point = (Point) o;
        return Double.compare(point.x, x) == 0 &&
                Double.compare(point.y, y) == 0;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }

    @Override
    public String toString() {
        return "Point{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }
}
